import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useAppStore = defineStore('app', () => {
    // 主题
    const mode = ref('light')
    const toggleMode = () => {
        mode.value = mode.value === 'light' ? 'dark' : 'light'
    }
    // 钱包
    const wallet = ref('')
    const isConnect = ref(false)
    const mainNetValue = ref(0)
    const mainNetUnit = ref('')
    const dialogWallet = ref(false)
    const connectWallet = async () => {
        dialogWallet.value = true
    }
    const disConnectWallet = () => {
        dialogWallet.value = false
        isConnect.value = false
    }
    const choseWallet = () => {
        dialogWallet.value = false
        isConnect.value = true
        mainNetValue.value = '124'
        mainNetUnit.value = 'HNY'
    }
    // token选择
    const dialogSelectToken = ref(false)
    const toggleSelectToken = () => {
        dialogSelectToken.value = !dialogSelectToken.value
    }
    // swap_liquidity_referral tab
    const tabActive = ref(0)
    const setTabActive = (index) => {
        tabActive.value = index
    }

    return {
        mode,
        wallet,
        isConnect,
        mainNetValue,
        mainNetUnit,
        dialogWallet,
        dialogSelectToken,
        tabActive,
        toggleMode,
        connectWallet,
        disConnectWallet,
        choseWallet,
        toggleSelectToken,
        setTabActive
    }
})
